$(function() {

	$(".widt").click(function(){
		localStorage.clear();
	})


	/*
		logo切换 
	*/
	//获取所要操作的节点对象(浮动的元素(nav_li),出现的上面的线(nav_border),浮动时出现的div(nav_list))
	var nav_pa = document.getElementById("nav_pa");
	var nav_list = nav_pa.getElementsByClassName("nav_list"); //浮动时出现的div(nav_list)
	//console.log(nav_list);
	var nav_li = nav_pa.getElementsByClassName("nav_li"); //获取浮动的元素(nav_li)
	var nav_border = document.getElementById("nav_border") //出现的上面的线(nav_border)
	for(var i = 0; i < nav_li.length; i++) { //循环遍历每一个浮动元素节点对象
		//sconsole.log(nav_list.length);
		nav_li[i].index = i;
		nav_li[i].onmouseenter = function() { //鼠标浮动到元素上时执行函数
			for(var j = 0; j < nav_li.length; j++) { //循环遍历每一个浮动时出现的盒子
				nav_list[j].style.display = "none";
				nav_border.style.display = "none";
			}
			nav_list[this.index].style.display = "block";
			nav_border.style.display = "block";
		}
		nav_li[i].onmouseleave = function() {
			nav_border.style.display = "none";
			for(var j = 0; j < nav_li.length; j++) { //循环遍历每一个浮动时出现的盒子
				nav_list[j].style.display = "none";
			}
		}
	}
	
	var isLogin = localStorage["isLogin"];
	var username = localStorage["userName"]
	if(isLogin){
		$(".topright ul").eq(0).css({display:"none"});
		$(".topright ul").eq(1).css({display:"block"});
		$(".topright ul").eq(1).find("li").eq(0).find("span").text(username);
	}else{
		$(".topright ul").eq(0).css({display:"block"});
		$(".topright ul").eq(1).css({display:"none"});
	}
	/*
		侧边切换 
	*/
	var banleft_ul = document.getElementById("banleft_ul");
	var banleft_li = document.getElementsByClassName("banleft_li");
	var banleft_list = document.getElementsByClassName("banleft_list");
	for(var x = 0; x < banleft_li.length; x++) {
		//console.log(banleft_li.length);
		//console.log(banleft_list);
		banleft_li[x].index = x
		banleft_li[x].onmouseenter = function() {
			for(var y = 0; y < banleft_li.length; y++) {
				banleft_list[y].style.display = "none";
			}
			banleft_list[this.index].style.display = "block";
		}
		banleft_li[x].onmouseleave = function() {
			for(var y = 0; y < banleft_li.length; y++) {
				banleft_list[y].style.display = "none";
			}
		}
	}

	//轮播初始化
	var mySwiper = new Swiper('.swiper-container', {
		autoplay: 2000,
		speed: 800,
		autoplayDisableOnInteraction: false,
		loop: true,
		prevButton: '.swiper-button-prev',
		nextButton: '.swiper-button-next',
		pagination: '.swiper-pagination',
		paginationClickable: true,
		effect: 'fade',
		fade: {
			crossFade: true,
		}
	})

	/*
    	banner图的点击  点击跳转到活动页面
    */
	$('.banner_five').click(function(){
		window.location.href = 'active.html';
	})
	
	/*
		小米明星单品的点击切换 
	*/
	$('#main_left').click(function(){
		$('.main_dlm').css('margin-left','-1240px');
		$('#main_right').addClass('active');
		$('#main_left').removeClass('active')
	})
	$('#main_right').click(function(){
		$('.main_dlm').css('margin-left','0');
		$('#main_left').addClass('active');
		$('#main_right').removeClass('active')
	})

	/*main 的运动*/
	$(".phon_mf img,.one_dl .one_pc1,.one_dl dl,.main_two dl,.two_img,.main_three dl,.main_four dl,.main_six dl,.seven_list,.main_eight dl").hover(function() {
		$(this).css({
			'margin-top': '0',
			'box-shadow': '0 15px 30px rgba(0,0,0,0.1)',
		})
	}, function() {
		$(this).css({
			'margin-top': '',
			'box-shadow': '0 0 0 rgba(0,0,0,0)'
		})
	})
	/*
		main_six 第六部分的运动和阴影 
	*/
	$(".main_six dl").hover(function() {
		$(this).css({
			'margin-top': '-10px',
			'box-shadow': '0 15px 30px rgba(0,0,0,0.1)'
		})
	}, function() {
		$(this).css({
			'margin-top': '',
			'box-shadow': '0 0 0 rgba(0,0,0,0)'
		})
	})
	
	
	/*
		main_two 第二部分的鼠标滑过的效果 
	*/
	$('.two_list').children().hover(function(){
		$('.text_posi').eq($(this).index).css('bottom','0');
	},function(){
		$('.text_posi').eq($(this).index).css('bottom','-100px');
	})
	
	/*
		鼠标滑过出现提示框 
	*/
	$(".main_two,.main_three").find("dl").hover(function() {
		$(this).children(".text_posi").stop().animate({
			bottom: "0px"
		}, 200);
	}, function() {
		$(this).children(".text_posi").stop().animate({
			bottom: "-100px"
		}, 200)
	})
	
	/*
		main_two 第二部分的切换
	*/
	
	$('.two_p li a').mouseenter(function(){
		$(".two_list").eq($(this).index()).css("display","block");
	},function(){
		$(".two_list").eq($(this).index()).css("display","block");
	})
	
})